<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	
	var_dump($ssFilter);
	//--------------------- Tim kiem --------------------//	
	$keywords 		= $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	$linkSearch 	= $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch 		= $this->formButton('search-now','Tìm',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch = $this->formButton('clear-keywords','Xóa',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	
	$optionsThang=array("0"=> '- Tất cả -',"01"=> 'Tháng 1',"02"=> 'Tháng 2',"03"=> 'Tháng 3',"04"=> 'Tháng 4',"05"=> 'Tháng 5',"06"=> 'Tháng 6',"07"=> 'Tháng 7',"08"=> 'Tháng 8',"09"=> 'Tháng 9',"10"=> 'Tháng 10',"11"=> 'Tháng 11',"12"=> 'Tháng 12');
	
	$date = new Zend_Date();
	$dateNamnay = $date->toString('YYYY');
	$dateNam = $dateNamnay;
	if(isset($ssFilter['date_nam'])) {
		$dateNam = $ssFilter['date_nam'];
	}
	
	$date = new Zend_Date();
	$dateThangnay = $date->toString('MM') ;
	if(isset($ssFilter['date_thang'])) {
		$dateThangnay = $ssFilter['date_thang'];
	}
	
	for ($i = 0; $i <= 10; $i++){
		$optionsNam[$dateNamnay-$i] = $dateNamnay-$i;
	}
	$linkSlbThang		 	= $this->baseUrl($this->currentController . '/filter/type/date_thang/' . $this->arrParam['date_thang']);
	$selectThang 			= $this->formSelect('date_thang',$dateThangnay,array('onchange'=>"OnSubmitForm('" .$linkSlbThang ."')"), $optionsThang);
	$linkSlbNam			 	= $this->baseUrl($this->currentController . '/filter/type/date_nam/' . $this->arrParam['date_nam']);
	$selectNam	 			= $this->formSelect('date_nam',$dateNam,array('onchange'=>"OnSubmitForm('" .$linkSlbNam ."')"), $optionsNam);
	
	
	$linkSlbCategory = $this->baseUrl($this->currentController . '/filter/type/category');
	$selectCategory = $this->cmsSelect('parents',$ssFilter['parents'],$this->slbCategory,array('style'=>'min-width:200px;','onchange'=>"OnSubmitForm('" .$linkSlbCategory ."')"));
	
	$strSearch 		= $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;
	$strSearchRight = $selectCategory.''. $selectNam .' '. $selectThang ;
?>

<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
</div>
<?php 


//  function listdoanhthu($ssFilter){
		
// 	$id			=$ssFilter['id'];
// 	$nam		=$ssFilter['nam'];
// 	$thang		=$ssFilter['thang'];
// 	$filter = new Zend_Filter_Alnum(true);
// 	$db = Zend_Registry::get('connectDb');
// 	//$db = Zend_Db::factory($adapter, $config);
	 
// 	$sql ='SELECT nam_hopdong SET count = count + 1 WHERE id=' .$id;
// 	$db->query($sql);

// }
// ?>
<div class="right_content">
	<div class="appContent">
		<form action="" method="post" name="appForm">
			<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
			<?php
			if($this->arrParam['save'] == 'ok'){
				echo '<div class="thongbaoThanhCong goc5">Xử lý dữ liệu thành công</div>';
			} 
			?>
			<div class="formList goc5">
				<div class="appTop goct5">
					<div class="block_filter">
						<div class="fl">
							<div class="listSearch">
								<?php echo $strSearch; ?>
								<div class="clr"></div>			
							</div>
						</div>
						<div class="fr">
							<div class="listSelect">
								<?php echo $strSearchRight;?>
								<div class="clr"></div>
							</div>
						</div>
						<div class="clr"></div>
					</div>
				</div>
				<div class="appBody">
					<table class="tblList">
						<tr>
							<th width="20">#</th>
							<th width="20"><input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()"></th>
							<th>Tên phòng ban</th>
							<th width="100">Đơn Giá <br/> hợp đồng</th>
							<th width="100">Thành tiền <br/> sau khuyến mại</th>
							<th width="100">Số tiền <br/> đã thu</th>
							<th width="100">Khách hàng <br/>còn nợ</th>
							<th width="100">ID Phòng ban</th>
						</tr>
						<?php
						if(count($this->Items) > 0){
							foreach ($this->Items as $key => $val){
								$id 			= $val['id'];
								$name 			= $val['name'];
								$parents 		= $val['parents'];
								$user_name 		= $val['user_name'];
								$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style'=>'width: 30px; text-align: center;'));
									
								$status 		= $val['status'];
								if($status == 1){
									$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);
									$status = $this->cmsIconButton('Kích vào để tắt', $this->imgUrl . '/admin/tick.png', $linkStatus);
								}else{
									$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);
									$status = $this->cmsIconButton('Kích vào để bật', $this->imgUrl . '/admin/publish_x.png', $linkStatus);
								}
								$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id);
								$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
								
								$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id);
								$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
									
								$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id);
								$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
								
								$strIconButton 	= $btnInfo . $btnEdit . $btnDelete;
									
								$name 	= '<a href="' . $linkEdit . '">' . $name . '</a>';
								if($val['level'] == 1){
									$name = '<strong>' . $name . '</strong>';
								}else{
									$string = '<span class="gi">|—</span>';
									$newString = '';
									$newAlias = '';
									for($i=1;$i<$val['level'];$i++){
										$newString 	.= $string;
									}
									$name = $newString . $name;
								}
								
								$cid 			= $this->formCheckbox('cid[]',$val['id']);
								$classRow = 'row1';
								if($key % 2 == 0)
									$classRow = '';
						?>
						<tr class="<?php echo $classRow;?>">
							<td align="center"><?php echo $key + 1;?></td>
							<td align="center"><?php echo $cid;?></td>
							<td align="left"><?php echo $name;?></td>
							<td align="center">12345789</td>
							<td align="center">12345789</td>
							<td align="center">12345789</td>
							<td align="center">12345789</td>
							<td align="center"><?php echo $id;?></td>
						</tr>
						<?php
							}
						}
						?>
					</table>
				</div>
				<div class="appBottom">
					
				</div>
			</div>
		</form>
	</div>
</div>
<div class="clr"></div>
